<template lang='pug'>
.page
  .NodeManage
    .pl-20.pr-20.bg-white
      .parma-list
        .parma-item(v-for="(item, index) of formItem")
          .parma-item-title {{item.title}}
          .parma-item-desc(v-if='item.key!="attachmentList"') {{infoList[item.key]}}
          .parma-item-desc(v-if='item.key=="attachmentList"')
            Poptip(trigger="hover" title="合同附件" :disabled="infoList[item.key].length == 0")
              div(slot="content" style='z-index:999;')
                .u-d-info(v-for="(item, index) in infoList[item.key]" :key="index" @click="handleDownLoad(item)") {{item.name}}
              Button(:disabled="infoList[item.key].length == 0") 查看
      Table.hasTitle-table.beautiful-table(:columns="nodeThead" :data="this.infoList.enjoyAuditList" :stripe="true")
        .clearfix.font-16(slot="header")
          .pull-right.table-title-btns
        template(slot-scope="{ row, index }" slot="action")
          Poptip(trigger="hover" title="合同附件" :disabled="row.fileList.length == 0")
            div(slot="content" style='z-index:999;')
              .u-d-info(v-for="(item, index) in row.fileList" :key="index" @click="handleDownLoad(item)") {{item.name}}
            Button(:disabled="row.fileList.length == 0") 查看
</template>

<script>
import config from '@/config'
import { Common } from '@/utils/common.js'
import dataApi from '@/api/data.js'
import { SysBasedataApi } from '@/api/SysBasedata.api.js'
import { TreatmentEnjoyManageApi } from '@/api/TreatmentEnjoyManage.api.js'
import { editNodeThead, editCityThead } from './tableHead.js'
import _cloneDeep from 'clone-deep'
// const baseUrl = process.env.NODE_ENV === 'development' ? config.baseUrl.dev : config.baseUrl.pro
const baseUrl = process.env.NODE_ENV === 'development' ? config.baseUrl.dev : config.baseUrl.pro.replace('/api', '/')

export default {
  name: 'editNode',

  components: {
  },

  data () {
    return {
      id: null,
      parameterId: null,
      nodeThead: _cloneDeep(editNodeThead),
      nodeTable: [],
      nodeTableComone: {
        pageIndex: 1, // 页码
        totalRows: 0, // 总条数
        pageSize: 30, // 当前页面展示条数
        agentCount: 0,
        doneCount: 0,
      },
      formData: {
        parameterTypeEnumName: null,
        parameterName: null,
        parameterStatus: null,
        whetherDistinguishCitie: null,
        rowVersion: null
      },
      formItem: [
        {
          title:'客户名称：',
          key:'customerName'
        },
        {
          title:'姓名：',
          key:'accoutName'
        },
        {
          title:'身份证号码：',
          key:'idCardNo'
        },
        {
          title:'参保险种：',
          key:'insuredTypeName'
        },
        {
          title:'待遇名称：',
          key:'treatmentName'
        },
        {
          title:'参保城市：',
          key:'areaAllName'
        },
        {
          title:'商保编号：',
          key:'securityNO'
        },
        {
          title:'个人编号：',
          key:'personalCode'
        },
        {
          title:'参保基数：',
          key:'declareSalary'
        },
        {
          title:'参保时间：',
          key:'add_DeclareDate'
        },
        {
          title:'附件：',
          key:'attachmentList'
        }
      ],
      infoList:{},
      isChangeSort: false,
      actionKey: null
    }
  },

  mounted () {
    console.log(this.$route.query)
    this.id = this.$route.query.id
    this.getModel()
  },

  computed: {
  },

  methods: {
    // 搜索
    searchFn () {
      this.getModel()
    },

    /**
     * 分页查询接口
     * @param {Object} obj {pageIndex, pageSize}
     */
    async getModel () {
      var params = {
        id: this.id,
        enjoyType: 3
      }
      let res = await TreatmentEnjoyManageApi.getModel(params)
      if (res.status === 200 && res.data.success) {
        this.infoList = res.data.data ? res.data.data : {}
        if (this.infoList.enjoyAuditList.length>0) {
          let result = this.infoList.enjoyAuditList
          for (var j in result) {
            let annexNameArr = result[j].annexName?result[j].annexName.split(','):result[j].annexName
            let pathArr = result[j].path?result[j].path.split(','):result[j].path
            let idArr = result[j].annexId?result[j].annexId.split(','):result[j].annexId
            let fileList = []
            for (var i in pathArr) {
              fileList[i]={
                path: pathArr[i],
                name: annexNameArr[i],
                id: idArr[i]
              }
            }
            result[j].fileList = fileList
          }
        }
        console.log(this.infoList,'infolist')
      } else {
        this.infoList= {}
      }
      this.loading = false
    },
    
    // 附件下载
    handleDownLoad (row) {
      var url = baseUrl + '/Attachment/Download?id=' + row.id
      window.open(url, '_blank')
    }
  }
}
</script>

<style lang="less">
  .parma-list{
    display: flex;
    flex-direction: row;
    align-items: center;
    // justify-content: space-around;
    flex-wrap: wrap;
    .parma-item{
      width: 25%;
      height: 50px;
      display: flex;
      flex-direction: row;
      align-items: center;
      // margin-right: 20px;
      font-size: 14px;
      .parma-item-title{}
      .parma-item-desc{}
    }
  }
          
</style>
